package main

import "fmt"

// 数组分页

func main() {
	arr := []int{1, 2}
	// data := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33}
	size := 3
	max := int(len(arr))
	if max <= size {
		fmt.Println(arr)
		return
	}
	//获取应该数组分割为多少份
	var quantity int
	if max%size == 0 {
		quantity = max / size
	} else {
		quantity = (max / size) + 1
	}
	var start, end, i int
	for i = 1; i <= quantity; i++ {
		end = i * size
		if i != quantity {
			fmt.Println(arr[start:end])
		} else {
			fmt.Println(arr[start:])
		}
		start = i * size
	}
}
